﻿using System;
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Wala.Connection.Objects.Timeline
{
    public class CommentData
    {
        private List<FeedComment> feed;

        public List<FeedComment> Feed
        {
            get { return feed; }
            set { feed = value; }
        }

        public CommentData()
        {
            this.Feed = new List<FeedComment>();
        }

        public List<Comment> GetListComments()
        {
            List<Comment> data = new List<Comment>();
            foreach (FeedComment comment in feed)
            {
                if (comment.type != 0)
                {
                    data.Add(comment.data);
                }
            }
            return data;
        }

        public static CommentData FromJson(string json)
        {
            try
            {
                CommentData commentData;
                commentData = JsonConvert.DeserializeObject<CommentData>(json);                
                return commentData;
            }
            catch (Exception ex)
            {
                return new CommentData();
            }
        }
    }
}
